package com.Alan.util;

import lombok.Getter;
import lombok.Setter;
import org.junit.Test;

public final class Paging {
//    当前页数
    @Getter @Setter
    private int pageIndex = 1;
//    开始行 0开始
    @Setter
    private int startRow = 0;
//    一页多少行
    @Getter @Setter
    private int pageRows = 8;
//    所有行
    @Getter @Setter
    private int allSize;
//    一共多少页
    private int pageCount;

    public int getPageCount() {
        return (int) Math.ceil((double) allSize / (double) pageRows);
    }

    public int getStartRow(){
        return (pageIndex - 1) * pageRows;
    }

    @Test
    public void text(){
        Paging paging = new Paging();
        System.out.println(paging.getPageCount());
    }
}
